﻿using FoodModel;
using J.FoodManageGet.Application.Command.GroupingCommand;
using J.FoodRepository.InterFace;
using MediatR;

namespace J.FoodManageGet.Application.CommandHandler.GroupingCommandHandler
{
    public class GroupingBackCommandHandler : IRequestHandler<GroupingBackCommand, GroupingModel>
    {
        private readonly IGroupingRepository _groupingRepository;

        public GroupingBackCommandHandler(IGroupingRepository groupingRepository)
        {
            _groupingRepository = groupingRepository;
        }

        public async Task<GroupingModel> Handle(GroupingBackCommand request, CancellationToken cancellationToken)
        {
            var list = await _groupingRepository.GroupingBack(request.GroupingId);
            //var list1 = await _dishesReposittory.GetAllAsync();

            //var info=(from a in list
            //         join b in list1 on a.GroupingId equals b.GroupingId
            //         where (a.GroupingId== request.GroupingId)
            //         select new GroupingDto
            //         {
            //             DishesName = b.DishesName,
            //             DishId = b.DishId,
            //             GroupingId = a.GroupingId,
            //             GroupingName = a.GroupingName,
            //             GroupingNum = a.GroupingNum,
            //         }).ToList();
            return list;
        }
    }
}
